<template>
    <transition appear name="side_anime">
        <div>
            <div class="back">
                <el-button type="success" size="mini" @click="back">返回</el-button>
            </div>

            <el-table
                :data="mediRecord"
                style="width: 100%"
                :header-cell-style="{background:'#909399',color:'#fff'}">

                <el-table-column prop="recordId" label="诊断记录ID" width="120">
                </el-table-column>

                <el-table-column prop="medicineId" label="药物ID" width="120">
                </el-table-column>

                <el-table-column prop="medicineName" label="药物名" width="120">
                </el-table-column>

                <el-table-column prop="medicineType" label="药物类型" width="120">
                </el-table-column>

                <el-table-column prop="medicineNumber" label="药物数量" width="80">
                </el-table-column>

                <el-table-column prop="medicinePrice" label="药物单价" width="80">
                </el-table-column>

                <el-table-column prop="specifications" label="药物规格" width="120">
                </el-table-column>

                <el-table-column prop="usaged" label="用法" width="120">
                </el-table-column>

                <el-table-column prop="advice" label="医嘱" width="150">
                </el-table-column>
            </el-table>
        </div>
    </transition>
    
</template>

<script>
import {queryMedicine} from '../../api/api'
export default {
    data(){
        return {
            mediRecord:[]
        }
    },
    mounted() {
        this.getMediRecord();
    },
    methods: {
        // 返回
        back(){
            this.$router.push("/homeview/takeMedicine")
        },

        //获取病人药物清单
        getMediRecord() {
            let token = this.$store.state.medicalStaff.loginData.tokenValue
            let header = {
                'satoken':token
            }
            let patientId = this.$route.params.id
            let data = {
                'userId':patientId
            }
            console.log(token)
            console.log(data)
            queryMedicine(data,header).then(response =>{
                console.log('请求成功',response)
                if(response.ret == '0'){
                    this.mediRecord = response.medicineRecords
                }else{
                    this.$message({
                        message:'获取失败',
                        type: 'error',
                        showClose:true
                    })
                }
            })
        }
    }
}
</script>

<style scoped>
.side_anime-enter-from,.side_anime-leave-to{
  opacity: 1;
}

.side_anime-enter-active{
  animation: slideInLeft 1s;
}

.side_anime-leave-active{
  animation: slideOutLeft 1s;
}
.back {
    text-align: left;
    margin-bottom: 20px;
}
</style>
